package com.bss.model;

import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.Transient;

@Entity
@Table(name = "BedBooking")
public class BedBooking extends Payable {

	private static final long serialVersionUID = -1225489456257940222L;

	private Admission admission = new Admission();

	private Bed bed = new Bed();

	private Integer rate;

	private Date checkInDate = new Date();

	private Date checkOutDate = new Date();

	private Integer totalPayment;

	private Integer pendingPayment;

	private Integer payment;

	@ManyToOne(fetch = FetchType.EAGER)
	@JoinColumn(name = "idAdmission")
	public Admission getAdmission() {
		return this.admission;
	}

	public void setAdmission(final Admission admission) {
		this.admission = admission;
	}

	@ManyToOne(fetch = FetchType.EAGER)
	@JoinColumn(name = "idBed")
	public Bed getBed() {
		return this.bed;
	}

	public void setBed(final Bed bed) {
		this.bed = bed;
	}

	@Column(name = "rate")
	public Integer getRate() {
		return this.rate;
	}

	public void setRate(final Integer rate) {
		this.rate = rate;
	}

	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = "checkInDate", length = 19)
	public Date getCheckInDate() {
		return this.checkInDate;
	}

	public void setCheckInDate(final Date checkInDate) {
		this.checkInDate = checkInDate;
	}

	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = "checkOutDate", length = 19)
	public Date getCheckOutDate() {
		return this.checkOutDate;
	}

	public void setCheckOutDate(final Date checkOutDate) {
		this.checkOutDate = checkOutDate;
	}

	@Override
	public String toString() {
		return this.bed.getRoom().getBuilding().getName() + "(" + this.bed.getRoom() + "-" + this.bed.getBedNumber() + ")";
	}

	public void setTotalPayment(final Integer totalPayment) {
		this.totalPayment = totalPayment;
	}

	@Column(name = "totalPayment")
	public Integer getTotalPayment() {
		return this.totalPayment;
	}

	public void setPendingPayment(final Integer pendingPayment) {
		this.pendingPayment = pendingPayment;
	}

	@Transient
	public Integer getPendingPayment() {
		return this.pendingPayment;
	}

	public void setPayment(final Integer payment) {
		this.payment = payment;
	}

	@Transient
	public Integer getPayment() {
		return this.payment;
	}

}
